<?php
session_start();
if(isset($_SESSION['admin_id'])) {
    include('../include/dbFunctions.php');
    $_SESSION['mes']="";
    $school_id= $_SESSION['school_id'];
//Retrieve data from AJAX data sent by jEditable
$updateID = $_SESSION['id'];
    $school_name = htmlspecialchars($_POST['school_name'],ENT_QUOTES);
    $school_description = htmlspecialchars($_POST['school_description'],ENT_QUOTES);
    $school_address = htmlspecialchars($_POST['school_address'],ENT_QUOTES);
    $school_status = htmlspecialchars($_POST['school_status'],ENT_QUOTES);
    $school_postal = htmlspecialchars($_POST['school_postal'],ENT_QUOTES);
    $education_id = htmlspecialchars($_POST['school_education'],ENT_QUOTES);
    $location_id = htmlspecialchars($_POST['school_location'],ENT_QUOTES);
    $last_modified = date("Y-m-d H:i:s");

    $query1 = "UPDATE school
            SET school_name = '".$school_name."',
                school_description = '".$school_description."',
                school_address = '".$school_address."',
                school_status = '".$school_status."',
                school_postal = '".$school_postal."',
                education_id = '".$education_id."',
                location_id = '".$location_id."',
                last_modified = '".$last_modified."'
            WHERE school_id=$school_id";
$result1 = executeQuery($query1);
   if ($result1!=0) {
        $_SESSION['mes'] = "Your record has been added successfully.";
    } else {
        $_SESSION['mes'] = "Error! Please try again";
    }$link = "schoolView.php?id=$school_id";
    header("Location: $link ");

}else {
    header("Location: ../include/login.html");
}
?>
